package org.hs.phd.odi.tracking.performanceevaluation;

import java.awt.Polygon;
import java.awt.Rectangle;

import org.hs.phd.common.simpleplayer.ImageSequenceFrame;

public class TemporalOverlappingPercentageMetric extends AbstractTrackingPerformanceMetric {

	@Override
	protected float compute(ImageSequenceFrame frame, Polygon groundTruthTrackShape, Polygon computedTrackShape) {
		Rectangle gtBoundingBox = groundTruthTrackShape.getBounds();
		Rectangle compBoundingBox = computedTrackShape.getBounds();
		Rectangle overlap = gtBoundingBox.intersection(compBoundingBox);

		int overlapArea = overlap.width*overlap.height;

		return overlapArea == 0 ? 0 : 100;
	}

	@Override
	public String getShortName() {
		return "Temp.Ovr.%";
	}

	@Override
	public String getName() {
		return "Temporal Overlapping";
	}
	
	@Override
	public String getUnitName() {
		return "Percentage";
	}

	@Override
	public float getRangeMin() {
		return 0;
	}

	@Override
	public float getRangeMax() {
		return 100;
	}


}
